//
//  ActivityTableViewCell.m
//  A段项目
//
//  Created by dlios on 15/7/17.
//  Copyright (c) 2015年 dlios. All rights reserved.
//

#import "ActivityTableViewCell.h"
#import "BaseHeader.h"


@implementation ActivityTableViewCell

- (void)dealloc
{
    [_show release];
    [_title release];
    [_sponsor release];
    [_start release];
    [_end release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style    reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews
{
    UIView *back = [[UIView alloc] initWithFrame:CGRectMake(10, 10, ScreenWidth - 20, 280)];
    [self addSubview:back];
    [back release];
    back.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:0.7];
    
    self.show = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, back.frame.size.width - 20, back.frame.size.height / 3 * 2)];
    [back addSubview:_show];
    [_show release];
    
    self.title = [[UILabel alloc] initWithFrame:CGRectMake(10, _show.frame.origin.y + _show.frame.size .height + 10, back.frame.size.width - 20, 20)];
    _title.font = [UIFont systemFontOfSize:14];
    [back addSubview:_title];
    [_title release];
    
    self.sponsor = [[UILabel alloc] initWithFrame:CGRectMake(10, _title.frame.size.height + _title.frame.origin.y + 10, 200, 15)];
    _sponsor.textColor = [UIColor grayColor];
    _sponsor.font = [UIFont systemFontOfSize:13];
    [back addSubview:_sponsor];
    [_sponsor release];
    
    UILabel *date = [[UILabel alloc] initWithFrame:CGRectMake(10, _sponsor.frame.size.height + _sponsor.frame.origin.y + 5, 30, 15)];
    date.text = @"时间:";
    date.textColor = [UIColor grayColor];
    date.font = [UIFont systemFontOfSize:13];
    [back addSubview:date];
    [date release];
    
    self.start = [[UILabel alloc] initWithFrame:CGRectMake(date.frame.origin.x + 35, date.frame.origin.y, 80, 15)];
    _start.textColor = [UIColor grayColor];
    _start.font = [UIFont systemFontOfSize:13];
    [back addSubview:_start];
    [_start release];
    
    UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(_start.frame.origin.x + 75, _start.frame.origin.y, 15, 15)];
    lab.textColor = [UIColor grayColor];
    lab.text = @"至";
    lab.font = [UIFont systemFontOfSize:13];
    [back addSubview:lab];
    [lab release];
    
    self.end = [[UILabel alloc] initWithFrame:CGRectMake(lab.frame.origin.x + 17, lab.frame.origin.y, 80, 15)];
    _end.textColor= [UIColor grayColor];
    _end.font = [UIFont systemFontOfSize:13];
    [back addSubview:_end];
    [_end release];
    
    self.button = [[UIButton alloc] initWithFrame:CGRectMake(back.frame.size.width - 95, _sponsor.frame.origin.y + 10, 90, 25)];
    _button.layer.cornerRadius = 10;
    _button.layer.masksToBounds = YES;
    _button.titleLabel.font = [UIFont systemFontOfSize:15];
    [_button setTitle:@"马上报名" forState:UIControlStateNormal];
    _button.backgroundColor = [UIColor orangeColor];
    [_button addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    [back addSubview:_button];
    [_button release];
}

- (void)button:(id)sender
{
    [(NSObject *)self.target performSelector:self.action withObject:sender];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
